package com.dongline.test.join;

import com.dongline.test.huizongliuliang.FlowDriver;
import com.dongline.test.huizongliuliang.FlowMapper;
import com.dongline.test.huizongliuliang.FlowReducer;
import com.dongline.test.huizongliuliang.FlowWritable;
import com.dongline.test.mapjoin.MapJoinMapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class JoinDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

        Configuration configuration = new Configuration();
        Logger logger=  LoggerFactory.getLogger(MapJoinMapper.class);
        logger.info("ddddddddddddddddd");
        logger.error("woacao");

        Job job=Job.getInstance(configuration);

        ///这句话很重要必须加上
        job.setJarByClass(JoinDriver.class);


        job.setMapperClass(JoinMapper.class);
        job.setReducerClass(JoinReducer.class);


        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(OrderWritable.class);


        job.setOutputKeyClass(OrderWritable.class);
        job.setOutputValueClass(NullWritable.class);





        FileInputFormat.setInputPaths(job,new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));



//        job.setCombinerClass();可以设置一个Combiner，功能类似于reducer，但是是运行在maptask上的。maptask自己数据进行分区排序之前调用一次。分区排序后调用一次。业务场景



        boolean re= job.waitForCompletion(true);

        System.exit(re?0:1);
    }
}
